<?php

namespace app\api\controller\PayExchange;


use app\common\Log;
use app\common\Pay\SafePay;
use think\facade\Validate;

class PayNotify
{

    public function safePay()
    {
        $params = \request()->all();
        $validator = Validate::make($params, [
            'mer_no' => 'required',
            'order_no' => 'required',
            'order_amount' => 'required',
            'order_realityamount' => 'required',
            'paytypecode' => 'required',
//            'sign' => 'required',
        ]);

        if ($validator->fails()) {
            return 'err';
        }
        $pay = new SafePay(config('pay.safe_pay'));
        $ret = $pay->notify($params);
        Log::write('safepay支付回调本地响应：' . $pay->getErr(), 'pay', 'pay');
        return 'ok';

    }






}